#pragma once

#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include <initializer_list>

class pkg;
class data_center_t;

class xprocessing_t {
protected:
    std::shared_ptr<data_center_t> data_center_sptr_;

    void add(std::shared_ptr<xprocessing_t> pp);
    void remove(std::shared_ptr<xprocessing_t> pp);
    void set_err_info(int64_t code, const std::string& msg);

private:
    int64_t err_code_;
    std::string err_msg_;
    std::vector<std::shared_ptr<xprocessing_t>> processing_list_;

public:
    xprocessing_t(std::shared_ptr<data_center_t> data_center_sptr);
    xprocessing_t(std::vector<std::shared_ptr<xprocessing_t>> processor_list);
    virtual ~xprocessing_t();

    std::pair<int, std::string> get_err_info();

    virtual int handle_input(pkg& data);
};

/**
 * @brief 报价方检查
 * 
 */
class pricing_client_check_t : public xprocessing_t
{
private:
    /* data */
public:
    pricing_client_check_t (std::shared_ptr<data_center_t> data_center_sptr);
    virtual ~pricing_client_check_t();
    int handle_input(pkg& data) override;
};

/**
 * @brief 客户号矫正
 * 
 */
class client_id_corrected_t : public xprocessing_t
{
private:
    /* data */
public:
    client_id_corrected_t(std::shared_ptr<data_center_t> data_center_sptr);
    virtual ~client_id_corrected_t();
    int handle_input(pkg& data) override;
};


/**
 * @brief 会员号矫正
 * 
 */
class member_id_corrected_t : public xprocessing_t
{
private:
    /* data */
public:
    member_id_corrected_t(std::shared_ptr<data_center_t> data_center_sptr);
    virtual ~member_id_corrected_t();
    int handle_input(pkg& data) override;
};

/**
 * @brief 合约号存在性检查
 * 
 */
class contract_exist_check_t : public xprocessing_t
{
private:
    /* data */
public:
    contract_exist_check_t(std::shared_ptr<data_center_t> data_center_sptr);
    virtual ~contract_exist_check_t();
    int handle_input(pkg& data) override;
};

/**
 * @brief 合约是否已上市
 * 
 */
class contract_status_check_t : public xprocessing_t
{
private:
    /* data */
public:
    contract_status_check_t(std::shared_ptr<data_center_t> data_center_sptr);
    virtual ~contract_status_check_t();
    int handle_input(pkg& data) override;
};

/**
 * @brief 客户是否对合约进行过报价
 * 
 */
class client_contract_inputed_check_t : public xprocessing_t
{
private:
    /* data */
public:
    client_contract_inputed_check_t(std::shared_ptr<data_center_t> data_center_sptr);
    virtual ~client_contract_inputed_check_t();
    int handle_input(pkg& data) override;
};


/**
 * @brief 清算账号检查
 * 
 */
class clear_account_no_check_t : public xprocessing_t
{
private:
    /* data */
public:
    clear_account_no_check_t(std::shared_ptr<data_center_t> data_center_sptr);
    ~clear_account_no_check_t();
    int handle_input(pkg& data) override;
};